﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace MagicTheGathering.Core
{
    public class Deck
    {
        public List<ICard> Cards { get; set; }

        public List<ICard> SideBoard { get; set; }

        public Deck()
        {
            Cards = new List<ICard>();
            SideBoard = new List<ICard>();
        }

        public void AddCard(String oracleName)
        {
            throw new NotImplementedException();
        }

        public void RemoveCard(String oracleName)
        {
            var targetCard = Cards.FirstOrDefault(c => c.OracleName.Equals(oracleName));
            if (targetCard == null)
            {
                throw new InvalidOperationException("Target card does not exist in the deck.");
            }

            Cards.Remove(targetCard);
        }

        public void AddCardToSideBoard(String oracleName)
        {
            throw new NotImplementedException();
        }

        public void RemoveCardFromSideBoard(String oracleName)
        {
            var targetCard = SideBoard.FirstOrDefault(c => c.OracleName.Equals(oracleName));
            if (targetCard == null)
            {
                throw new InvalidOperationException("Target card does not presented in the sideboard.");
            }

            SideBoard.Remove(targetCard);
        }
    }
}
